//
//  AXSpellDetailsThirdCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/13.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXSpellDetailsThirdCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@interface AXSpellDetailsThirdCell ()
/** 线 */
@property (nonatomic , strong) UIView *lineView;

@end

@implementation AXSpellDetailsThirdCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** 店铺名 */
    self.storeNameLabel = [[UILabel alloc]init];
    self.storeNameLabel.text = @"安心100直销店";
    self.storeNameLabel.textAlignment = NSTextAlignmentLeft;
    self.storeNameLabel.font = FONT_FOURTEEN;;
    self.storeNameLabel.textColor = COLOR_Gray;
    [self.contentView addSubview:self.storeNameLabel];
    /** 待付款 */
    self.dfkButton = [[UIButton alloc]init];
    self.dfkButton.titleLabel.font = FONT_FOURTEEN;;
    [self.dfkButton setTitle:@"待分享 查5人" forState:UIControlStateNormal];
    [self.dfkButton setTitleColor:COLOR_ORG forState:UIControlStateNormal];
    [self.contentView addSubview:self.dfkButton];
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.image = [UIImage imageNamed:@"j8.jpg"];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.text =@"新疆葡萄";
    self.productNameLabel.font = FONT_FOURTEEN;;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 产品合计 */
    self.productCountLabel = [[UILabel alloc]init];
    self.productCountLabel.textColor = [UIColor colorWithHex:0x666666];
    self.productCountLabel.font = FONT_TWELVE;
    self.productCountLabel.text = @"共一件商品 合计 98（含运费10元）";
    [self.contentView addSubview:self.productCountLabel];
    /** 产品价格 */
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.text = @"￥12";
    self.priceLabel.textColor = COLOR_ORG;
    self.priceLabel.font = FONT_EIGHTEEN;
    [self.contentView addSubview:self.priceLabel];
    
    /** 数目 */
    self.countLabel = [[UILabel alloc]init];
    self.countLabel.textColor = COLOR_Gray;
    self.countLabel.font = FONT_TWELVE;
    self.countLabel.text = @"x1";
    [self.contentView addSubview:self.countLabel];
    
    /** 联系卖家*/
    self.contactView = [[UIView alloc]init];
    self.contactView.backgroundColor = COLOR_GREEN;
    [self.contentView addSubview:self.contactView];
    
    self.contactBtn = [[UIButton alloc]init];
    [self.contactBtn setImage:[UIImage imageNamed:@"contact"] forState:UIControlStateNormal];
    [self.contactView addSubview:self.contactBtn];
    
    self.contactLabel = [[UILabel alloc]init];
    self.contactLabel.text = @"联系卖家";
    self.contactLabel.textColor = [UIColor whiteColor];
    self.contactLabel.font = FONT_FOURTEEN;
    [self.contactView addSubview:self.contactLabel];
    
    /** 拨打电话 */
    self.callView = [[UIView alloc]init];
    self.callView.backgroundColor = COLOR_GREEN;
    [self.contentView addSubview:self.callView];
    
    self.callBtn = [[UIButton alloc]init];
    [self.callBtn setImage:[UIImage imageNamed:@"call"] forState:UIControlStateNormal];
    [self.callView addSubview:self.callBtn];
    
    self.callLabel = [[UILabel alloc]init];
    self.callLabel.text = @"拨打电话";
    self.callLabel.textColor = [UIColor whiteColor];
    self.callLabel.font = FONT_FOURTEEN;
    [self.callView addSubview:self.callLabel];
    
    
    /** 取消订单 */
    self.cancelButton = [[UIButton alloc]init];
    self.cancelButton.borderWidth = 1;
    self.cancelButton.borderColor = [UIColor colorWithHex:0x666666];
    self.cancelButton.cornerRadius = 5;
    self.cancelButton.titleLabel.font = FONT_FOURTEEN;;
    [self.cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
    [self.cancelButton setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
    [self.contentView addSubview:self.cancelButton];
    /** 去支付*/
    self.payButton = [[UIButton alloc]init];
    self.payButton.cornerRadius = 5;
    self.payButton.titleLabel.font = FONT_FOURTEEN;;
    self.payButton.backgroundColor = COLOR_ORG;
    [self.payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.payButton setTitle:@"邀请好友拼单" forState:UIControlStateNormal];
    [self.contentView addSubview:self.payButton];
    
    if (SCREEN_WIDTH <= 320) {
        self.productNameLabel.font = FONT_TWELVE;
        self.productCountLabel.font = FONT_TWELVE;
        self.priceLabel.font = FONT_TWELVE;
        self.cancelButton.titleLabel.font = [UIFont systemFontOfSize:10];
        self.payButton.titleLabel.font = FONT_TWELVE;
    }
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:self.lineView];
    
    
    
}

- (void)setlayout {
    /** 店铺名称 */
    self.storeNameLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(30);
    /** 待付款 */
    self.dfkButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(100)
    .heightIs(30);
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.dfkButton, 0)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.dfkButton, 0)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    
    /* 价格 **/
    self.priceLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .widthIs(50)
    .heightIs(30);
    
    self.countLabel.sd_layout
    .leftSpaceToView(self.priceLabel, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .widthIs(50)
    .heightIs(30);
    
    
    /* 产品合计 **/
    self.productCountLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.priceLabel, 0)
    .heightIs(30);
    
    self.contactView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productCountLabel, 10)
    .widthIs((SCREEN_WIDTH-30)/2)
    .heightIs(30);
    
    self.contactBtn.sd_layout
    .leftSpaceToView(self.contactView, 20)
    .topSpaceToView(self.contactView, 5)
    .widthIs(20)
    .heightIs(20);
    
    self.contactLabel.sd_layout
    .leftSpaceToView(self.contactBtn, 20)
    .topSpaceToView(self.contactView, 0)
    .widthIs(70)
    .heightIs(30);
    
    
    self.callView.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productCountLabel, 10)
    .widthRatioToView(self.contactView, 1)
    .heightRatioToView(self.contactView, 1);
    
    self.callBtn.sd_layout
    .leftSpaceToView(self.callView, 20)
    .topSpaceToView(self.callView, 5)
    .widthIs(20)
    .heightIs(20);
    
    self.callLabel.sd_layout
    .leftSpaceToView(self.callBtn,20)
    .topSpaceToView(self.callView, 0)
    .widthIs(70)
    .heightIs(30);
    
    
    
    /** 去支付按钮 */
    self.payButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.callView, 20)
    .widthIs(100)
    .heightIs(30);
    /** 取消按钮 */
    self.cancelButton.sd_layout
    .rightSpaceToView(self.payButton, 10)
    .topSpaceToView(self.callView,20)
    .widthIs(100)
    .heightIs(30);
    
    
    
    self.lineView.sd_layout
    .rightSpaceToView(self.contentView, 0)
    .topSpaceToView(self.cancelButton, 10)
    .widthIs(SCREEN_WIDTH)
    .heightIs(10);
    
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.lineView bottomMargin:10];
    
}

@end


